import {createRouter, createWebHistory} from 'vue-router'

import Layout from '@/views/layout/layout'

const _import = require('./_import_' + process.env.NODE_ENV)
// 定义路由配置
export const constantRouterMap = [
  { 
    path: '/',
    name: 'dashboard',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => _import('dashboard/index'),
        meta: {title: '首页'}
      },
      {
        path: 'memberlist',
        name: 'memberlist',
        component: () => _import('member/index'),
        meta: {title: '人员管理'}
      },
      {
        path: 'fileExport',
        name: 'fileExport',
        component: () => _import('file/index'),
        meta: {title: '文件流下载'}
      },
      {
        path: 'pdfPreview',
        name: 'pdfPreview',
        component: () => _import('pdf/index'),
        meta: {title: 'PDF预览'}
      }
    ] 
  }
];

export default createRouter({
  // 4.0 采用 history 模式
  history: createWebHistory(),
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap,
})
